package com.study.selection.service;

import com.study.selection.dao.NewsDao;
import com.study.selection.model.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {

    @Autowired
    private NewsDao newsDao;

    @Override
    public List<News> findAll() {
        return newsDao.findAll();
    }

    @Override
    public List<News> findByKey(String key) {
        return newsDao.findByKey(key);
    }

    @Override
    public boolean addNews(News news) {
        return newsDao.addNews(news) > 0 ? true : false;
    }

    @Override
    public News getById(int news_id) {
        return newsDao.getById(news_id);
    }

    @Override
    public boolean updateNews(News news) {
        return newsDao.updateNews(news) > 0 ? true : false;
    }
    @Override
    public boolean deleteNews(int news_id) {
        return newsDao.deleteNews(news_id) > 0 ? true : false;
    }


}

